home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
program
/
recio214.zip
/
DESIGN.TXT
< prev
next >
Wrap
Text File
|
1996-06-14
|
18KB
|
397 lines
Title: RECIO DESIGN AND DEVELOPMENT NOTES
Copyright: (C) 1994-1996, William Pierpoint
Version: 2.14
Date: June 14, 1996
1.0 DATA STRUCTURES
1.1 REC structure for each record stream
* defined in recio.h.
* 3 (!dos) or 4 (dos) static RECs for recin, recout, etc (included in
ROPEN_MAX count).
* allocate dynamic array of RECs dimensioned to ROPEN_MAX-NREC in ropen().
* Each REC has two associated buffers:
1) record string buffer containing current record;
allocate when first record read;
reallocate if record becomes larger.
2) field string buffer containing current field;
allocate when first field read;
reallocate if field becomes larger.
* deallocate dynamic RECs and associated buffers in rclose() and
rcloseall() if all record streams closed; deallocate associated
buffers for recin with an exit function registered with atexit().
1.2 REC r_flags assignments
Bit Description
----- -------------------------------------------------------------
0 If clear, colno start at 0; if set, colno start at 1
1 if clear, read mode; if set, write/append mode
2 if clear, current field not quoted by r_txtch;
if set, current field quoted by r_txtch.
3-6 Reserved for future use.
7 If clear, EOF not reached; if set, EOF reached
8-11 If clear, no error; else rerror number
12-15 if clear, no warning; else rwarning number
1.3 Accessing REC Members and Associated Buffers
How do I
* access the name of the record stream? rnames()
* access the current context number? rcxtno()
* access the current record number? rrecno()
* access the current field number? rfldno()
* access the current column number? rcolno()
* access the record string buffer? rrecs()
* access the field string buffer? rflds()
* determine the number of fields in a record? rnumfld()
* determine if column numbers start at 0 or 1? rbegcolno()
* determine if the current field was quoted? ristxtfld()
* determine if there are more records left? reof()
* determine if there is an error on the stream? rerror()
* determine if there is a warning on the stream? rwarning()
* access the error message for the stream? rerrstr()
* force an error on a record stream? rseterr()
* clear an error on a record stream? rclearerr()
* scan the record buffer more than once? rresetrec()
* increase the size of the record string buffer? rsetrecsiz()
* increase the size of the field string buffer? rsetfldsiz()
* replace the data in the field string buffer? rsetfldstr()
* replace the data in the record string buffer? rsetrecstr()
* get/set position of a field in a record? rgetfldpos()/rsetfldpos()
* set the field delimiter character? rsetfldch()
* set the text delimiter character? rsettxtch()
* set the time format string? rsettmfmt()
* set the context number? rsetcxtno()
* set column numbering to start at 0 or 1? rsetbegcolno()
* dynamically copy a string? scpys()
* dynamically concatenate a string? scats()
* trim white space from the ends of a string? strims()
2.0 CODE STRUCTURES
2.1 RECIO Structure Chart
╔═════════╗ ╔═════════╗
║ rstr.c ║ ║ recio.c ║
╚════╤════╝ ╚═╤══╤══╤═╝
│ │ │ │
│ ╔════════╗ input │ │ │ output ╔════════╗
└────╢ rget.c ╟───────────┘ │ └──────────╢ rput.c ║
char ╚═╤════╤═╝ column │ char ╚═╤════╤═╝ column
delimited │ │ delimited │ delimited │ │ delimited
╔═════════╗ │ │ ╔══════════╗ │ ╔═════════╗ │ │ ╔══════════╗
║ rgetf.c ╟─┤ ├─╢ rcgetf.c ║ │ ║ rputf.c ╟─┤ ├─╢ rcputf.c ║
╚═════════╝ │ │ ╚══════════╝ │ ╚═════════╝ │ │ ╚══════════╝
│ │ │ │ │
╔═════════╗ │ │ ╔══════════╗ │ ╔═════════╗ │ │ ╔══════════╗
║ rgets.c ╟─┤ ├─╢ rcgets.c ║ │ ║ rputs.c ╟─┤ ├─╢ rcputs.c ║
╚═════════╝ │ │ ╚══════════╝ │ ╚═════════╝ │ │ ╚══════════╝
│ │ │ │ │
╔═════════╗ │ │ ╔══════════╗ │ ╔═════════╗ │ │ ╔══════════╗
║ rgett.c ╟─┤ ├─╢ rcgett.c ║ │ ║ rputt.c ╟─┤ ├─╢ rcputt.c ║
╚═════════╝ │ │ ╚══════════╝ │ ╚═════════╝ │ │ ╚══════════╝
│ │ │ │ │
╔═════════╗ │ │ ╔══════════╗ │ ╔═════════╗ │ │ ╔══════════╗
║ rbget.c ╟─┘ └─╢ rcbget.c ║ │ ║ rbput.c ╟─┘ └─╢ rcbput.c ║
╚═════════╝ ╚══════════╝ │ ╚═════════╝ ╚══════════╝
│
╔══════════╗ │ ╔═════════╗ ╔══════════╗
║ rwarn.c ╟───┴───╢ rerr.c ╟────────╢ rfix.c ║
╚════╤═════╝ ╚════╤════╝ ╚══════════╝
│ │
╔════╧═════╗ ╔════╧════╗
║ rwmsg.c ║ ║ remsg.c ║
╚══════════╝ ╚═════════╝
2.2 Callback Error Functions
The callback error function technique used by the RECIO library can
be applied within your programs to other abstract data types. For
abstract data types within the standard C library, you will need to
write wrapper functions.
╔═════════╗
║ errnofn ║
╚════╤════╝
│
┌──────────────┼──────────────┬───── etc
│ │ │
╔════╧════╗ ╔════╧════╗ ╔════╧════╗
║ rerrfn ║ ║ ferrfn ║ ║ merrfn ║
╚═════════╝ ╚═════════╝ ╚═════════╝
REC FILE MEMORY
2.2.1 Errno Callback Error Function Skeleton [errnofn()]
switch on error number [errno]
case out of memory [ENOMEM]
case out of range [ERANGE]
case out of record or file pointers [EMFILE]
case permission denied [EACCES]
case invalid argument [EINVAL]
default [anything else]
endcase
2.2.2 RECIO Callback Error Function Skeleton [rerrfn(rp)]
if valid record pointer [risvalid(rp)]
if past end of file [reof(rp)] (if reof test removed, past EOF will
else [error number set] become R_EMISDAT or R_WEMPSTR)
switch on error number [rerror(rp)]
case read data errors [R_ERANGE || R_EINVDAT || R_EMISDAT]
case write data errors [R_ENOPUT]
switch on context number [rcxtno(rp)]
case RECIN
switch field number [rfldno(rp)]
case 1 (first field read)
case 2 (second field read)
...
endcase
...
default [missing or unknown context number]
endcase
case out of memory [R_ENOMEM]
case fatal errors [R_EINVAL || R_EINVMOD]
default [anything else]
endcase
endif
else [invalid record pointer]
call error function that handles errno errors [errnofn()]
endif
2.3 RECIO Callback Warning Function Skeleton [rwarnfn(rp)]
if valid record pointer [risvalid(rp)]
switch on warning number [rwarning(rp)]
case read data warnings [R_WEMPSTR || R_WTMFMT]
case write data warnings [R_WWIDTH]